package com.lzp.wechat.controller;

import com.lzp.wechat.service.MediaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "素材管理接口")
@RequestMapping("/media")
public class MediaController {

    @Autowired
    private MediaService mediaService;

    @PostMapping("/upload")
    @ApiOperation(value = "新增临时素材", notes = "新增临时素材")
    public String mediaUpload(@RequestPart("file") MultipartFile file) {
        return mediaService.mediaUpload(file);
    }

    @GetMapping("/get")
    @ApiOperation(value = "获取临时素材", notes = "获取临时素材")
    public void getMediaById(@RequestParam("media_id") String media_id, HttpServletResponse response) {
        mediaService.getMediaById(media_id, response);
    }

}
